golang http request with cookie Posted on 2015-06-16 | Edited on 2019-02-04 | Comments: 123456789101112131415161718192021 url := "http://127.0.0.1:8998"req, err := http.NewRequest("POST", url, nil)if err != nil { log.Error(err) return}cookie := http.Cookie{Name: "cookie_name", Value: "cookie_value"}req.AddCookie(&cookie)var client = &http.Client{}resp, err := client.Do(req)if err != nil { log.Error(err) return}defer resp.Body.Close()ret, err := ioutil.ReadAll(resp.Body)if err != nil { return}